﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Class1
    {
        private static string constr = "server=.;database=DB;uid=sa;pwd=1234567";
        private static string tsql = "select * from Users";
        public static void outdate()
        {


            SqlDataAdapter sqldataAdapter = new SqlDataAdapter(tsql, constr);


            DataTable dataTable = new DataTable();

            sqldataAdapter.Fill(dataTable);



            Console.WriteLine("{0}\t{1}\t\t{2}", "编号", "姓名", "年龄");
            
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                Console.WriteLine("{0}\t{1}\t{2}", dataTable.Rows[i]["UserId"], dataTable.Rows[i]["UserName"], dataTable.Rows[i]["UserAge"]);
            }
        }

    }
}
